//
//  LNavigationBar.m
//  s.
//
//  Created by fanshijian on 2022/8/30.
//  Copyright © 2022 J. All rights reserved.
//

#import "LNavigationBar.h"

@interface LNavigationBar ()

@property (weak, nonatomic) UILabel *titleLab;
@property (weak, nonatomic) UIButton *backBtn;

@end

@implementation LNavigationBar

- (UILabel *)titleLab {
    if (!_titleLab) {
        UILabel *obj = [UILabel new];
        [self addSubview:_titleLab = obj];
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            kMakeTV(klStatusBarHeight);
            kMakeHV(44);
            kMakeBV(0);
            kMakeCenterXV(0);
            kMakeLV(80);
        }];
        obj.font = U_bfont(18);
        obj.textColor = KLColor(@"#000000");
        obj.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLab;
}

- (UIButton *)backBtn {
    if (!_backBtn) {
        UIButton *obj = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:_backBtn = obj];
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            kMakeWHV(44, 44);
            kMakeLV(10);
            kMakeTV(klStatusBarHeight);
        }];
        [obj setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
        obj.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
        obj.imageEdgeInsets = kEdge(5, 10, 5, 10);
    }
    return _backBtn;
}

- (void)setBackAction:(NSDictionary *)backAction {
    self.backBtn.zh_action = backAction;
}

- (void)setBackHidden:(BOOL)backHidden {
    self.backBtn.hidden = backHidden;
}

- (void)setTitle:(NSString *)title {
    self.titleLab.text = title;
}

- (void)setTitleColor:(NSString *)titleColor {
    self.titleLab.textColor = KLColor(titleColor);
}

@end
